package elsa.controller;

import java.io.File;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import elsa.bootmapper.UserMapper;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import elsa.bean.*;
import elsa.tools.*;
import elsa.bootmapper.OpsMapper;
import com.github.pagehelper.PageHelper;

@Controller
public class OpsController {

    @Autowired
    private OpsMapper opsMapper;

    @Autowired
    private UserMapper userMapper;

    /*
     * 营运检验操作
     */
    //信息提醒 搜索 兼 分页
    @CrossOrigin
    @RequestMapping(value="/reminder/ops", method = RequestMethod.GET)
    @ResponseBody
    @RequiresPermissions("public")
    public MyResp opsInfoReminder(@RequestParam("pageIndex") Integer pageIndex,
                          @RequestParam("pageSize") Integer pageSize,
                          @RequestParam(value="value",required = false,defaultValue = "null") String value,
                          @RequestParam(value="type",required = false,defaultValue = "null") String type){
        if(pageIndex==null){
            pageIndex=1;
        }
        if(pageSize==null){
            pageSize=10;
        }
        Subject subject = SecurityUtils.getSubject();
        ScsUser scsUser =(ScsUser) subject.getPrincipal();
        String id = scsUser.getUserid();
        String Role = userMapper.findRole(scsUser.getUserid()).getRole();
        switch (Role){
            case "管理员":
            case "负责人":
                PageHelper.startPage(pageIndex, pageSize);
                switch (type){
                    case "rgstnum":
                        return  MyResp.render(0,"获取成功",opsMapper.opsInfoReminderByRgstnum(value),opsMapper.opsInfoReminderCountByRgstnum(value));
                    case "shipname":
                        return  MyResp.render(0,"获取成功",opsMapper.opsInfoReminderByShipname(value),opsMapper.opsInfoReminderCountByShipname(value));
                    case "":
                        return MyResp.render(0,"获取成功",opsMapper.opsInfoReminder(),opsMapper.opsInfoReminderCount());
                    default:
                        return MyResp.render(0,"获取成功",opsMapper.opsInfoReminder(),opsMapper.opsInfoReminderCount());
                }
            case "验船师":
                PageHelper.startPage(pageIndex, pageSize);
                switch (type){
                    case "rgstnum":
                        return  MyResp.render(0,"获取成功",opsMapper.opsYcsInfoReminderByRgstnum(value, id),opsMapper.opsYcsInfoReminderCountByRgstnum(value, id));
                    case "shipname":
                        return  MyResp.render(0,"获取成功",opsMapper.opsYcsInfoReminderByShipname(value, id),opsMapper.opsYcsInfoReminderCountByShipname(value, id));
                    case "":
                        return MyResp.render(0,"获取成功",opsMapper.opsYcsInfoReminder(id),opsMapper.opsYcsInfoReminderCount(id));
                    default:
                        return MyResp.render(0,"获取成功",opsMapper.opsYcsInfoReminder(id),opsMapper.opsYcsInfoReminderCount(id));
                }
            case "船厂"	:
                PageHelper.startPage(pageIndex, pageSize);
                switch (type){
                    case "rgstnum":
                        return  MyResp.render(0,"获取成功",opsMapper.opsCcInfoReminderByRgstnum(value, id),opsMapper.opsCcInfoReminderCountByRgstnum(value, id));
                    case "shipname":
                        return  MyResp.render(0,"获取成功",opsMapper.opsCcInfoReminderByShipname(value, id),opsMapper.opsCcInfoReminderCountByShipname(value, id));
                    case "":
                        return MyResp.render(0,"获取成功",opsMapper.opsCcInfoReminder(id),opsMapper.opsCcInfoReminderCount(id));
                    default:
                        return MyResp.render(0,"获取成功",opsMapper.opsCcInfoReminder(id),opsMapper.opsCcInfoReminderCount(id));
                }
            case "船东"	:
                PageHelper.startPage(pageIndex, pageSize);
                switch (type){
                    case "rgstnum":
                        return  MyResp.render(0,"获取成功",opsMapper.opsCdInfoReminderByRgstnum(value,id),opsMapper.opsCdInfoReminderCountByRgstnum(value,id));
                    case "shipname":
                        return  MyResp.render(0,"获取成功",opsMapper.opsCdInfoReminderByShipname(value,id),opsMapper.opsCdInfoReminderCountByShipname(value,id));
                    case "":
                        return MyResp.render(0,"获取成功",opsMapper.opsCdInfoReminder(id),opsMapper.opsCdInfoReminderCount(id));
                    default:
                        return MyResp.render(0,"获取成功",opsMapper.opsCdInfoReminder(id),opsMapper.opsCdInfoReminderCount(id));
                }
            default:
                return null;
        }
    }

    //营运检验历史查询 兼 搜索  兼 分页
    @CrossOrigin
    @RequestMapping(value="/project/ops/history", method = RequestMethod.GET)
    @ResponseBody
    @RequiresPermissions("public")
    public MyResp opsHistoryList(@RequestParam("pageIndex") Integer pageIndex,
                                   @RequestParam("pageSize") Integer pageSize,
                                   @RequestParam(value="value",required = false,defaultValue = "null") String value,
                                   @RequestParam(value="type",required = false,defaultValue = "null") String type){
        if(pageIndex==null){
            pageIndex=1;
        }
        if(pageSize==null){
            pageSize=10;
        }
        PageHelper.startPage(pageIndex, pageSize);
        switch (type){
            case "rgstnum":
                return MyResp.render(0,"获取成功",opsMapper.historyRgstnumOps(value),opsMapper.historyRgstnumOpsCount(value));
            case "shipname":
                return MyResp.render(0,"获取成功",opsMapper.historyShipnameOps(value),opsMapper.historyShipnameOpsCount(value));
            case "":
                return MyResp.render(0,"获取成功",opsMapper.historyAllOps(),opsMapper.historyAllOpsCount());
            default:
                return MyResp.render(0,"获取成功",opsMapper.historyAllOps(),opsMapper.historyAllOpsCount());
        }
    }

    //查询所有营运检验兼 搜索  兼 分页
    @CrossOrigin
    @RequestMapping(value="/project/ops/all", method = RequestMethod.GET)
    @ResponseBody
    @RequiresPermissions("public")
    public MyResp opslist(@RequestParam("pageIndex") Integer pageIndex,
                          @RequestParam("pageSize") Integer pageSize,
                          @RequestParam(value="value",required = false,defaultValue = "null") String value,
                          @RequestParam(value="type",required = false,defaultValue = "null") String type){
        if(pageIndex==null){
            pageIndex=1;
        }
        if(pageSize==null){
            pageSize=10;
        }
        Subject subject = SecurityUtils.getSubject();
        ScsUser scsUser =(ScsUser) subject.getPrincipal();
        String id = scsUser.getUserid();
        String Role = userMapper.findRole(scsUser.getUserid()).getRole();
        switch (Role){
            case "管理员":
            case "负责人":
                PageHelper.startPage(pageIndex, pageSize);
                switch (type){
                    case "rgstnum":
                        return  MyResp.render(0,"获取成功",opsMapper.findAllOpsByRgstnum(value),opsMapper.findOpsCountByRgstnum(value));
                    case "shipname":
                        return  MyResp.render(0,"获取成功",opsMapper.findAllOpsByShipname(value),opsMapper.findOpsCountByShipname(value));
                    case ""	:
                        return MyResp.render(0,"获取成功",opsMapper.findAllOps(),opsMapper.findOpsCount());
                    default:
                        return MyResp.render(0,"获取成功",opsMapper.findAllOps(),opsMapper.findOpsCount());
                }
            case "验船师":
                PageHelper.startPage(pageIndex, pageSize);
                switch (type){
                    case "rgstnum":
                        return  MyResp.render(0,"获取成功",opsMapper.findYcsOpsByRgstnum(value, id),opsMapper.findYcsOpsCountByRgstnum(value, id));
                    case "shipname":
                        return  MyResp.render(0,"获取成功",opsMapper.findYcsOpsByShipname(value, id),opsMapper.findYcsOpsCountByShipname(value, id));
                    case ""	:
                        return MyResp.render(0,"获取成功",opsMapper.findYcsOps(id),opsMapper.findYcsOpsCount(id));
                    default:
                        return MyResp.render(0,"获取成功",opsMapper.findYcsOps(id),opsMapper.findYcsOpsCount(id));
                }
            case "船厂"	:
                PageHelper.startPage(pageIndex, pageSize);
                switch (type){
                    case "rgstnum":
                        return  MyResp.render(0,"获取成功",opsMapper.findCcOpsByRgstnum(value, id),opsMapper.findCcOpsCountByRgstnum(value, id));
                    case "shipname":
                        return  MyResp.render(0,"获取成功",opsMapper.findCcOpsByShipname(value, id),opsMapper.findCcOpsCountByShipname(value, id));
                    case ""	:
                        return MyResp.render(0,"获取成功",opsMapper.findCcOps(id),opsMapper.findCcOpsCount(id));
                    default:
                        return MyResp.render(0,"获取成功",opsMapper.findCcOps(id),opsMapper.findCcOpsCount(id));
                }
            case "船东"	:
                PageHelper.startPage(pageIndex, pageSize);
                switch (type){
                    case "rgstnum":
                        return  MyResp.render(0,"获取成功",opsMapper.findCdOpsByRgstnum(value, id),opsMapper.findCdOpsCountByRgstnum(value, id));
                    case "shipname":
                        return  MyResp.render(0,"获取成功",opsMapper.findCdOpsByShipname(value, id),opsMapper.findCdOpsCountByShipname(value, id));
                    case ""	:
                        return MyResp.render(0,"获取成功",opsMapper.findCdOps(id),opsMapper.findCdOpsCount(id));
                    default:
                        return MyResp.render(0,"获取成功",opsMapper.findCdOps(id),opsMapper.findCdOpsCount(id));
                }
            default:
                return null;
        }
    }

    //营运检验会议
    @CrossOrigin
    @RequestMapping(value="/project/ops/meeting/{rgstnum}", method = RequestMethod.GET)
    @ResponseBody
    public GroupMess constmeeting(@PathVariable("rgstnum") String rgstnum){
        if(rgstnum==null){
            rgstnum="";
        }
        if(opsMapper.findOpsByRgstnum(rgstnum)!=null){
            ScsOpsinsp scsOpsinsp = opsMapper.findOpsByRgstnum(rgstnum);
            String a[] = scsOpsinsp.getCcinfo().split("/");
            String ccusername = a[1];
            String ccname = a[0];
            if(scsOpsinsp.getCdname()==null){
                scsOpsinsp.setCdname("");
            }
            if(scsOpsinsp.getCdusername()==null){
                scsOpsinsp.setCdusername("");
            }
            if(scsOpsinsp.getYcs1name()==null){
                scsOpsinsp.setYcs1name("");
            }
            if(scsOpsinsp.getYcs1username()==null){
                scsOpsinsp.setYcs1username("");
            }
            if(scsOpsinsp.getYcs2name()==null){
                scsOpsinsp.setYcs2name("");
            }
            if(scsOpsinsp.getYcs2username()==null){
                scsOpsinsp.setYcs2username("");
            }
            if(scsOpsinsp.getYcs3name()==null){
                scsOpsinsp.setYcs3name("");
            }
            if(scsOpsinsp.getYcs3username()==null){
                scsOpsinsp.setYcs3username("");
            }
            return GroupMess.reder(scsOpsinsp.getCdname(),scsOpsinsp.getCdusername(), scsOpsinsp.getYcs1name(), scsOpsinsp.getYcs1username(), scsOpsinsp.getYcs2name(), scsOpsinsp.getYcs2username(), scsOpsinsp.getYcs3name(), scsOpsinsp.getYcs3username(), ccname, ccusername);
        }else {
            return GroupMess.reder("","","","","","","","","","");
        }
    }

    //查询营运检验信息
    @CrossOrigin
    @RequestMapping(value="/project/ops/{rgstnum}", method = RequestMethod.GET)
    @ResponseBody
    @RequiresPermissions("public")
    public ScsOpsinsp opsInfo(@PathVariable("rgstnum") String rgstnum){
        if(rgstnum==null){
            rgstnum = "";
        }
        return opsMapper.findOpsByRgstnum(rgstnum);
    }

    //打印营运检验申请表
    @CrossOrigin
    @RequestMapping(value="/project/ops/print/{rgstnum}", method = RequestMethod.GET)
    @ResponseBody
    @RequiresPermissions("public")
    public ScsOpsinsp printOpsInfo(@PathVariable("rgstnum") String rgstnum){
        if(rgstnum==null){
            rgstnum = "";
        }
        return opsMapper.printOps(rgstnum);
    }

    //新建营运检验-船厂/船东提交
    @CrossOrigin
    @RequestMapping(value = "/project/ops/new/cc",method = RequestMethod.POST)
    @ResponseBody
    @RequiresPermissions(value = {"shipyard","admin","shipowner"},logical= Logical.OR)
    public Message addOps(@RequestBody ScsOpsinsp scsOpsinsp){
        return new Message(setAddOps(scsOpsinsp));
    }

    //更新营运检验-船厂提交
    @CrossOrigin
    @RequestMapping(value = "/project/ops/update/cc", method = RequestMethod.PUT)
    @ResponseBody
    @RequiresPermissions(value = {"shipyard","admin","head","shipowner"},logical= Logical.OR)
    public Message updateOps(@RequestBody ScsOpsinsp scsOpsinsp){
        return new Message(setUpdateOps(scsOpsinsp));
    }

    //更新营运检验-船检处审核
    @CrossOrigin
    @RequestMapping(value = "/project/ops/update/cjc", method = RequestMethod.PUT)
    @ResponseBody
    @RequiresPermissions(value = {"admin","head"},logical= Logical.OR)
    public Message updateOpsCjc(@RequestBody ScsOpsinsp scsOpsinsp){
        return new Message(setUpdateOpsCjc(scsOpsinsp));
    }

    //禁用营运检验
    @CrossOrigin
    @RequestMapping(value = "/project/ops/forbid/{rgstnum}", method = RequestMethod.PUT)
    @ResponseBody
    @RequiresPermissions("admin")
    public Message forbidOps(@PathVariable("rgstnum") String rgstnum){
        return new Message(setForbidOps(rgstnum));
    }

    //恢复营运检验
    @CrossOrigin
    @RequestMapping(value = "/project/ops/renew/{rgstnum}", method = RequestMethod.PUT)
    @ResponseBody
    @RequiresPermissions("admin")
    public Message renewOps(@PathVariable("rgstnum") String rgstnum){
        return new Message(setRenewOps(rgstnum));
    }

    //删除营运检验
    @CrossOrigin
    @RequestMapping(value = "/project/ops/delete/{rgstnum}", method = RequestMethod.PUT)
    @ResponseBody
    @RequiresPermissions("admin")
    public Message deleteOps(@PathVariable("rgstnum") String rgstnum){
        return new Message(setDeleteOps(rgstnum));
    }


    /*
     * 质量控制表操作
     */
    //查看质量控制表信息
    @CrossOrigin
    @RequestMapping(value="/project/ops/qcc/{rgstnum}", method = RequestMethod.GET)
    @ResponseBody
    @RequiresPermissions("public")
    public ScsQcc findQccInfo(@PathVariable("rgstnum") String rgstnum){
        if(rgstnum==null){
            rgstnum="";
        }
        return opsMapper.findQccByRgstnum(rgstnum);
    }

    //打印质量控制表信息
    @CrossOrigin
    @RequestMapping(value="/project/ops/qcc/print", method = RequestMethod.GET)
    @ResponseBody
    @RequiresPermissions("public")
    public ScsQcc printQccInfo(@RequestParam("rgstnum") String rgstnum){
        if(rgstnum==null){
            rgstnum="";
        }
        return opsMapper.printQcc(rgstnum);
    }

    //新建质量控制表
    @CrossOrigin
    @RequestMapping(value = "/project/ops/qcc/new",method = RequestMethod.POST)
    @ResponseBody
    @RequiresPermissions(value = {"surveyor","admin"},logical= Logical.OR)
    public Message addQcc(@RequestBody ScsQcc scsQcc){
        return new Message(setAddQcc(scsQcc));
    }

    //更新质量控制表
    @CrossOrigin
    @RequestMapping(value = "/project/ops/qcc/update", method = RequestMethod.PUT)
    @ResponseBody
    @RequiresPermissions(value = {"surveyor","admin"},logical= Logical.OR)
    public Message updateQcc(@RequestBody ScsQcc scsQcc){
        return new Message(setUpdateQcc(scsQcc));
    }

    //更新质量控制表-船东意见
    @CrossOrigin
    @RequestMapping(value = "/project/ops/qcc/updateCd", method = RequestMethod.PUT)
    @ResponseBody
    @RequiresPermissions(value = {"shipowner","admin"},logical= Logical.OR)
    public Message updateQccCd(@RequestBody ScsQcc scsQcc){
        return new Message(setUpdateQccCd(scsQcc));
    }


    /*
     * 船体设备效益试验记录表操作
     */
    //查看船体设备效益试验记录表信息
    @CrossOrigin
    @RequestMapping(value="/project/ops/ct/{rgstnum}", method = RequestMethod.GET)
    @ResponseBody
    @RequiresPermissions("public")
    public ScsNotect findCtInfo(@PathVariable("rgstnum") String rgstnum){
        if(rgstnum==null){
            rgstnum="";
        }
        return opsMapper.findNotectByRgstnum(rgstnum);
    }

    //打印船体设备效益试验记录表信息
    @CrossOrigin
    @RequestMapping(value="/project/ops/ct/print", method = RequestMethod.GET)
    @ResponseBody
    @RequiresPermissions("public")
    public ScsNotect printCtInfo(@RequestParam("rgstnum") String rgstnum){
        if(rgstnum==null){
            rgstnum="";
        }
        return opsMapper.printNotect(rgstnum);
    }

    //新建船体设备效益试验记录表
    @CrossOrigin
    @RequestMapping(value = "/project/ops/ct/new",method = RequestMethod.POST)
    @ResponseBody
    @RequiresPermissions(value = {"surveyor","admin"},logical= Logical.OR)
    public Message addNotect(@RequestBody ScsNotect scsNotect){
        String b;
        if(scsNotect.getRgstnum()!=null&&opsMapper.findNotect(scsNotect.getRgstnum())!=null){
            b = "船体设备效益试验记录表已存在!";
        }else if (scsNotect.getRgstnum()==null||!chickRgstnum(scsNotect.getRgstnum())){
            b = "船检登记号格式错误!";
        }else if (scsNotect.getCtname()==null||!chickPeoplename(scsNotect.getCtname())){
            b = "填写人格式错误!";
        }else if (scsNotect.getCtt1jg()==null||scsNotect.getCtt1bz()==null||scsNotect.getCtt2jg()==null||scsNotect.getCtt2bz()==null||scsNotect.getCtt3jg()==null||scsNotect.getCtt3bz()==null||scsNotect.getCtt4jg()==null||scsNotect.getCtt4bz()==null){
            b = "实验记录填写错误!";
        }else if (scsNotect.getCtt5jg()==null||scsNotect.getCtt5bz()==null||scsNotect.getCtt6jg()==null||scsNotect.getCtt6bz()==null||scsNotect.getCtt7jg()==null||scsNotect.getCtt7bz()==null||scsNotect.getCtt8jg()==null||scsNotect.getCtt8bz()==null){
            b = "实验记录填写错误!";
        }else if (scsNotect.getCtt9jg()==null||scsNotect.getCtt9bz()==null||scsNotect.getCtt10jg()==null||scsNotect.getCtt10bz()==null||scsNotect.getCtt11jg()==null||scsNotect.getCtt11bz()==null){
            b = "实验记录填写错误!";
        }else if (!BoolNote(scsNotect.getCtt1jg())||!BoolNote(scsNotect.getCtt2jg())||!BoolNote(scsNotect.getCtt3jg())||!BoolNote(scsNotect.getCtt4jg())){
            b = "实验记录填写错误!";
        }else if (!BoolNote(scsNotect.getCtt5jg())||!BoolNote(scsNotect.getCtt6jg())||!BoolNote(scsNotect.getCtt7jg())||!BoolNote(scsNotect.getCtt8jg())){
            b = "实验记录填写错误!";
        }else if (!BoolNote(scsNotect.getCtt9jg())||!BoolNote(scsNotect.getCtt10jg())||!BoolNote(scsNotect.getCtt11jg())){
            b = "实验记录填写错误!";
        }else {
            ScsOpsinsp scsOpsinsp = new ScsOpsinsp();
            if(BoolNotect(scsNotect)){
                if(opsMapper.findNotelj(scsNotect.getRgstnum())!=null&&opsMapper.findNotelj(scsNotect.getRgstnum()).getLjstate().equals("完成")&&opsMapper.findNotedq(scsNotect.getRgstnum())!=null&&opsMapper.findNotedq(scsNotect.getRgstnum()).getDqstate().equals("完成")){
                    scsOpsinsp.setAllstate("完成");
                    opsMapper.completeOps(scsNotect.getRgstnum());
                }else{
                    scsOpsinsp.setAllstate("船体效用记录表验船师完成");
                }
                scsNotect.setCtstate("完成");
            }else{
                scsOpsinsp.setAllstate("船体效用记录表验船师受理");
                scsNotect.setCtstate("未完成");
            }
            scsOpsinsp.setAlltime(getNtime());
            scsOpsinsp.setRgstnum(scsNotect.getRgstnum());
            opsMapper.updateAll(scsOpsinsp);
            scsNotect.setCtdate(getNtime());
            opsMapper.saveNotect(scsNotect);
            b = "船体设备效益试验记录表创建成功!";
        }
        return new Message(b);
    }

    //更新船体设备效益试验记录表
    @CrossOrigin
    @RequestMapping(value = "/project/ops/ct/update", method = RequestMethod.PUT)
    @ResponseBody
    @RequiresPermissions(value = {"surveyor","admin"},logical= Logical.OR)
    public Message updateNotect(@RequestBody ScsNotect scsNotect){
        String b;
        if(scsNotect.getRgstnum()!=null&&opsMapper.findNotect(scsNotect.getRgstnum())==null){
            b = "船体设备效益试验记录表不存在!";
        }else if (scsNotect.getRgstnum()==null||!chickRgstnum(scsNotect.getRgstnum())){
            b = "船检登记号格式错误!";
        }else if (scsNotect.getCtname()==null||!chickPeoplename(scsNotect.getCtname())){
            b = "填写人格式错误!";
        }else if (scsNotect.getCtt1jg()==null||scsNotect.getCtt1bz()==null||scsNotect.getCtt2jg()==null||scsNotect.getCtt2bz()==null||scsNotect.getCtt3jg()==null||scsNotect.getCtt3bz()==null||scsNotect.getCtt4jg()==null||scsNotect.getCtt4bz()==null){
            b = "实验记录填写错误!";
        }else if (scsNotect.getCtt5jg()==null||scsNotect.getCtt5bz()==null||scsNotect.getCtt6jg()==null||scsNotect.getCtt6bz()==null||scsNotect.getCtt7jg()==null||scsNotect.getCtt7bz()==null||scsNotect.getCtt8jg()==null||scsNotect.getCtt8bz()==null){
            b = "实验记录填写错误!";
        }else if (scsNotect.getCtt9jg()==null||scsNotect.getCtt9bz()==null||scsNotect.getCtt10jg()==null||scsNotect.getCtt10bz()==null||scsNotect.getCtt11jg()==null||scsNotect.getCtt11bz()==null){
            b = "实验记录填写错误!";
        }else if (!BoolNote(scsNotect.getCtt1jg())||!BoolNote(scsNotect.getCtt2jg())||!BoolNote(scsNotect.getCtt3jg())||!BoolNote(scsNotect.getCtt4jg())){
            b = "实验记录填写错误!";
        }else if (!BoolNote(scsNotect.getCtt5jg())||!BoolNote(scsNotect.getCtt6jg())||!BoolNote(scsNotect.getCtt7jg())||!BoolNote(scsNotect.getCtt8jg())){
            b = "实验记录填写错误!";
        }else if (!BoolNote(scsNotect.getCtt9jg())||!BoolNote(scsNotect.getCtt10jg())||!BoolNote(scsNotect.getCtt11jg())){
            b = "实验记录填写错误!";
        }else {
            ScsOpsinsp scsOpsinsp = new ScsOpsinsp();
            if(BoolNotect(scsNotect)){
                if(opsMapper.findNotelj(scsNotect.getRgstnum())!=null&&opsMapper.findNotelj(scsNotect.getRgstnum()).getLjstate().equals("完成")&&opsMapper.findNotedq(scsNotect.getRgstnum())!=null&&opsMapper.findNotedq(scsNotect.getRgstnum()).getDqstate().equals("完成")){
                    scsOpsinsp.setAllstate("完成");
                    opsMapper.completeOps(scsNotect.getRgstnum());
                }else{
                    scsOpsinsp.setAllstate("船体效用记录表验船师完成");
                }
                scsNotect.setCtstate("完成");
            }else{
                scsOpsinsp.setAllstate("船体效用记录表验船师受理");
                scsNotect.setCtstate("未完成");
            }
            scsOpsinsp.setAlltime(getNtime());
            scsOpsinsp.setRgstnum(scsNotect.getRgstnum());
            opsMapper.updateAll(scsOpsinsp);
            scsNotect.setCtdate(getNtime());
            opsMapper.updateNotect(scsNotect);
            b = "更新船体设备效益试验记录表成功!";
        }
        return new Message(b);
    }


    /*
     * 轮机设备效益试验记录表操作
     */
    //查看轮机设备效益试验记录表信息
    @CrossOrigin
    @RequestMapping(value="/project/ops/lj/{rgstnum}", method = RequestMethod.GET)
    @ResponseBody
    @RequiresPermissions("public")
    public ScsNotelj findLjInfo(@PathVariable("rgstnum") String rgstnum){
        if(rgstnum==null){
            rgstnum="";
        }
        return opsMapper.findNoteljByRgstnum(rgstnum);
    }

    //打印轮机设备效益试验记录表信息
    @CrossOrigin
    @RequestMapping(value="/project/ops/lj/print", method = RequestMethod.GET)
    @ResponseBody
    @RequiresPermissions("public")
    public ScsNotelj printLjInfo(@RequestParam("rgstnum") String rgstnum){
        if(rgstnum==null){
            rgstnum="";
        }
        return opsMapper.printNotelj(rgstnum);
    }

    //新建轮机设备效益试验记录表
    @CrossOrigin
    @RequestMapping(value = "/project/ops/lj/new",method = RequestMethod.POST)
    @ResponseBody
    @RequiresPermissions(value = {"surveyor","admin"},logical= Logical.OR)
    public Message addNotelj(@RequestBody ScsNotelj scsNotelj){
        String b;
        if(scsNotelj.getRgstnum()!=null&&opsMapper.findNotelj(scsNotelj.getRgstnum())!=null){
            b = "轮机设备效益试验记录表已存在!";
        }else if (scsNotelj.getRgstnum()==null||!chickRgstnum(scsNotelj.getRgstnum())){
            b = "船检登记号格式错误!";
        }else if (scsNotelj.getLjname()==null||!chickPeoplename(scsNotelj.getLjname())){
            b = "填写人格式错误!";
        }else if (scsNotelj.getLjt1jg()==null||scsNotelj.getLjt1bz()==null||scsNotelj.getLjt2jg()==null||scsNotelj.getLjt2bz()==null||scsNotelj.getLjt3jg()==null||scsNotelj.getLjt3bz()==null||scsNotelj.getLjt4jg()==null||scsNotelj.getLjt4bz()==null){
            b = "实验记录填写错误!";
        }else if (scsNotelj.getLjt5jg()==null||scsNotelj.getLjt5bz()==null||scsNotelj.getLjt6jg()==null||scsNotelj.getLjt6bz()==null||scsNotelj.getLjt7jg()==null||scsNotelj.getLjt7bz()==null||scsNotelj.getLjt8jg()==null||scsNotelj.getLjt8bz()==null){
            b = "实验记录填写错误!";
        }else if (scsNotelj.getLjt9jg()==null||scsNotelj.getLjt9bz()==null||scsNotelj.getLjt10jg()==null||scsNotelj.getLjt10bz()==null||scsNotelj.getLjt11jg()==null||scsNotelj.getLjt11bz()==null||scsNotelj.getLjt12jg()==null||scsNotelj.getLjt12bz()==null){
            b = "实验记录填写错误!";
        }else if (!BoolNote(scsNotelj.getLjt1jg())||!BoolNote(scsNotelj.getLjt2jg())||!BoolNote(scsNotelj.getLjt3jg())||!BoolNote(scsNotelj.getLjt4jg())){
            b = "实验记录填写错误!";
        }else if (!BoolNote(scsNotelj.getLjt5jg())||!BoolNote(scsNotelj.getLjt6jg())||!BoolNote(scsNotelj.getLjt7jg())||!BoolNote(scsNotelj.getLjt8jg())){
            b = "实验记录填写错误!";
        }else if (!BoolNote(scsNotelj.getLjt9jg())||!BoolNote(scsNotelj.getLjt10jg())||!BoolNote(scsNotelj.getLjt11jg())||!BoolNote(scsNotelj.getLjt12jg())){
            b = "实验记录填写错误!";
        }else {
            ScsOpsinsp scsOpsinsp = new ScsOpsinsp();
            if(BoolNotelj(scsNotelj)){
                if(opsMapper.findNotect(scsNotelj.getRgstnum())!=null&&opsMapper.findNotect(scsNotelj.getRgstnum()).getCtstate().equals("完成")&&opsMapper.findNotedq(scsNotelj.getRgstnum())!=null&&opsMapper.findNotedq(scsNotelj.getRgstnum()).getDqstate().equals("完成")){
                    scsOpsinsp.setAllstate("完成");
                    opsMapper.completeOps(scsNotelj.getRgstnum());
                }else{
                    scsOpsinsp.setAllstate("轮机效用记录表验船师完成");
                }
                scsNotelj.setLjstate("完成");
            }else{
                scsOpsinsp.setAllstate("轮机效用记录表验船师受理");
                scsNotelj.setLjstate("未完成");
            }
            scsOpsinsp.setAlltime(getNtime());
            scsOpsinsp.setRgstnum(scsNotelj.getRgstnum());
            opsMapper.updateAll(scsOpsinsp);
            scsNotelj.setLjdate(getNtime());
            opsMapper.saveNotelj(scsNotelj);
            b = "轮机设备效益试验记录表创建成功!";
        }
        return new Message(b);
    }

    //更新轮机设备效益试验记录表
    @CrossOrigin
    @RequestMapping(value = "/project/ops/lj/update", method = RequestMethod.PUT)
    @ResponseBody
    @RequiresPermissions(value = {"surveyor","admin"},logical= Logical.OR)
    public Message updateNotelj(@RequestBody ScsNotelj scsNotelj){
        String b;
        if(scsNotelj.getRgstnum()!=null&&opsMapper.findNotelj(scsNotelj.getRgstnum())==null){
            b = "轮机设备效益试验记录表不存在!";
        }else if (scsNotelj.getRgstnum()==null||!chickRgstnum(scsNotelj.getRgstnum())){
            b = "船检登记号格式错误!";
        }else if (scsNotelj.getLjname()==null||!chickPeoplename(scsNotelj.getLjname())){
            b = "填写人格式错误!";
        }else if (scsNotelj.getLjt1jg()==null||scsNotelj.getLjt1bz()==null||scsNotelj.getLjt2jg()==null||scsNotelj.getLjt2bz()==null||scsNotelj.getLjt3jg()==null||scsNotelj.getLjt3bz()==null||scsNotelj.getLjt4jg()==null||scsNotelj.getLjt4bz()==null){
            b = "实验记录填写错误!";
        }else if (scsNotelj.getLjt5jg()==null||scsNotelj.getLjt5bz()==null||scsNotelj.getLjt6jg()==null||scsNotelj.getLjt6bz()==null||scsNotelj.getLjt7jg()==null||scsNotelj.getLjt7bz()==null||scsNotelj.getLjt8jg()==null||scsNotelj.getLjt8bz()==null){
            b = "实验记录填写错误!";
        }else if (scsNotelj.getLjt9jg()==null||scsNotelj.getLjt9bz()==null||scsNotelj.getLjt10jg()==null||scsNotelj.getLjt10bz()==null||scsNotelj.getLjt11jg()==null||scsNotelj.getLjt11bz()==null||scsNotelj.getLjt12jg()==null||scsNotelj.getLjt12bz()==null){
            b = "实验记录填写错误!";
        }else if (!BoolNote(scsNotelj.getLjt1jg())||!BoolNote(scsNotelj.getLjt2jg())||!BoolNote(scsNotelj.getLjt3jg())||!BoolNote(scsNotelj.getLjt4jg())){
            b = "实验记录填写错误!";
        }else if (!BoolNote(scsNotelj.getLjt5jg())||!BoolNote(scsNotelj.getLjt6jg())||!BoolNote(scsNotelj.getLjt7jg())||!BoolNote(scsNotelj.getLjt8jg())){
            b = "实验记录填写错误!";
        }else if (!BoolNote(scsNotelj.getLjt9jg())||!BoolNote(scsNotelj.getLjt10jg())||!BoolNote(scsNotelj.getLjt11jg())||!BoolNote(scsNotelj.getLjt12jg())){
            b = "实验记录填写错误!";
        }else {
            ScsOpsinsp scsOpsinsp = new ScsOpsinsp();
            if(BoolNotelj(scsNotelj)){
                if(opsMapper.findNotect(scsNotelj.getRgstnum())!=null&&opsMapper.findNotect(scsNotelj.getRgstnum()).getCtstate().equals("完成")&&opsMapper.findNotedq(scsNotelj.getRgstnum())!=null&&opsMapper.findNotedq(scsNotelj.getRgstnum()).getDqstate().equals("完成")){
                    scsOpsinsp.setAllstate("完成");
                    opsMapper.completeOps(scsNotelj.getRgstnum());
                }else{
                    scsOpsinsp.setAllstate("轮机效用记录表验船师完成");
                }
                scsNotelj.setLjstate("完成");
            }else{
                scsOpsinsp.setAllstate("轮机效用记录表验船师受理");
                scsNotelj.setLjstate("未完成");
            }
            scsOpsinsp.setAlltime(getNtime());
            scsOpsinsp.setRgstnum(scsNotelj.getRgstnum());
            opsMapper.updateAll(scsOpsinsp);
            scsNotelj.setLjdate(getNtime());
            opsMapper.updateNotelj(scsNotelj);
            b = "更新轮机设备效益试验记录表成功!";
        }
        return new Message(b);
    }


    /*
     * 电气设备效益试验记录表操作
     */
    //查看电气设备效益试验记录表信息
    @CrossOrigin
    @RequestMapping(value="/project/ops/dq/{rgstnum}", method = RequestMethod.GET)
    @ResponseBody
    @RequiresPermissions("public")
    public ScsNotedq findDqInfo(@PathVariable("rgstnum") String rgstnum){
        if(rgstnum==null){
            rgstnum="";
        }
        return opsMapper.findNotedqByRgstnum(rgstnum);
    }

    //打印电气设备效益试验记录表信息
    @CrossOrigin
    @RequestMapping(value="/project/ops/dq/print", method = RequestMethod.GET)
    @ResponseBody
    @RequiresPermissions("public")
    public ScsNotedq printDqInfo(@RequestParam("rgstnum") String rgstnum){
        if(rgstnum==null){
            rgstnum="";
        }
        return opsMapper.printNotedq(rgstnum);
    }

    //新建电气设备效益试验记录表
    @CrossOrigin
    @RequestMapping(value = "/project/ops/dq/new",method = RequestMethod.POST)
    @ResponseBody
    @RequiresPermissions(value = {"admin","surveyor"},logical= Logical.OR)
    public Message addNotedq(@RequestBody ScsNotedq scsNotedq){
        String b;
        if(scsNotedq.getRgstnum()!=null&&opsMapper.findNotedq(scsNotedq.getRgstnum())!=null){
            b = "电气设备效益试验记录表已存在!";
        }else if (scsNotedq.getRgstnum()==null||!chickRgstnum(scsNotedq.getRgstnum())){
            b = "船检登记号格式错误!";
        }else if (scsNotedq.getDqname()==null||!chickPeoplename(scsNotedq.getDqname())){
            b = "填写人格式错误!";
        }else if (scsNotedq.getDqt1jg()==null||scsNotedq.getDqt1bz()==null||scsNotedq.getDqt2jg()==null||scsNotedq.getDqt2bz()==null||scsNotedq.getDqt3jg()==null||scsNotedq.getDqt3bz()==null||scsNotedq.getDqt4jg()==null||scsNotedq.getDqt4bz()==null){
            b = "实验记录填写错误!";
        }else if (scsNotedq.getDqt5jg()==null||scsNotedq.getDqt5bz()==null||scsNotedq.getDqt6jg()==null||scsNotedq.getDqt6bz()==null||scsNotedq.getDqt7jg()==null||scsNotedq.getDqt7bz()==null||scsNotedq.getDqt8jg()==null||scsNotedq.getDqt8bz()==null){
            b = "实验记录填写错误!";
        }else if (scsNotedq.getDqt9jg()==null||scsNotedq.getDqt9bz()==null||scsNotedq.getDqt10jg()==null||scsNotedq.getDqt10bz()==null||scsNotedq.getDqt11jg()==null||scsNotedq.getDqt11bz()==null||scsNotedq.getDqt12jg()==null||scsNotedq.getDqt12bz()==null){
            b = "实验记录填写错误!";
        }else if (!BoolNote(scsNotedq.getDqt1jg())||!BoolNote(scsNotedq.getDqt2jg())||!BoolNote(scsNotedq.getDqt3jg())||!BoolNote(scsNotedq.getDqt4jg())){
            b = "实验记录填写错误!";
        }else if (!BoolNote(scsNotedq.getDqt5jg())||!BoolNote(scsNotedq.getDqt6jg())||!BoolNote(scsNotedq.getDqt7jg())||!BoolNote(scsNotedq.getDqt8jg())){
            b = "实验记录填写错误!";
        }else if (!BoolNote(scsNotedq.getDqt9jg())||!BoolNote(scsNotedq.getDqt10jg())||!BoolNote(scsNotedq.getDqt11jg())||!BoolNote(scsNotedq.getDqt12jg())){
            b = "实验记录填写错误!";
        }else {
            ScsOpsinsp scsOpsinsp = new ScsOpsinsp();
            if (BoolNotedq(scsNotedq)){
                if(opsMapper.findNotect(scsNotedq.getRgstnum())!=null&&opsMapper.findNotect(scsNotedq.getRgstnum()).getCtstate().equals("完成")&&opsMapper.findNotelj(scsNotedq.getRgstnum())!=null&&opsMapper.findNotelj(scsNotedq.getRgstnum()).getLjstate().equals("完成")){
                    scsOpsinsp.setAllstate("完成");
                    opsMapper.completeOps(scsNotedq.getRgstnum());
                }else{
                    scsOpsinsp.setAllstate("电气效用记录表验船师完成");
                }
                scsNotedq.setDqstate("完成");
            }else{
                scsOpsinsp.setAllstate("电气效用记录表验船师受理");
                scsNotedq.setDqstate("未完成");
            }
            scsOpsinsp.setAlltime(getNtime());
            scsOpsinsp.setRgstnum(scsNotedq.getRgstnum());
            opsMapper.updateAll(scsOpsinsp);
            scsNotedq.setDqdate(getNtime());
            opsMapper.saveNotedq(scsNotedq);
            b = "电气设备效益试验记录表创建成功!";
        }
        return new Message(b);
    }

    //更新电气设备效益试验记录表
    @CrossOrigin
    @RequestMapping(value = "/project/ops/dq/update", method = RequestMethod.PUT)
    @ResponseBody
    @RequiresPermissions(value = {"admin","surveyor"},logical= Logical.OR)
    public Message updateNotedq(@RequestBody ScsNotedq scsNotedq){
        String b;
        if(scsNotedq.getRgstnum()!=null&&opsMapper.findNotedq(scsNotedq.getRgstnum())==null){
            b = "电气设备效益试验记录表不存在!";
        }else if (scsNotedq.getRgstnum()==null||!chickRgstnum(scsNotedq.getRgstnum())){
            b = "船检登记号格式错误!";
        }else if (scsNotedq.getDqname()==null||!chickPeoplename(scsNotedq.getDqname())){
            b = "填写人格式错误!";
        }else if (scsNotedq.getDqt1jg()==null||scsNotedq.getDqt1bz()==null||scsNotedq.getDqt2jg()==null||scsNotedq.getDqt2bz()==null||scsNotedq.getDqt3jg()==null||scsNotedq.getDqt3bz()==null||scsNotedq.getDqt4jg()==null||scsNotedq.getDqt4bz()==null){
            b = "实验记录填写错误!";
        }else if (scsNotedq.getDqt5jg()==null||scsNotedq.getDqt5bz()==null||scsNotedq.getDqt6jg()==null||scsNotedq.getDqt6bz()==null||scsNotedq.getDqt7jg()==null||scsNotedq.getDqt7bz()==null||scsNotedq.getDqt8jg()==null||scsNotedq.getDqt8bz()==null){
            b = "实验记录填写错误!";
        }else if (scsNotedq.getDqt9jg()==null||scsNotedq.getDqt9bz()==null||scsNotedq.getDqt10jg()==null||scsNotedq.getDqt10bz()==null||scsNotedq.getDqt11jg()==null||scsNotedq.getDqt11bz()==null||scsNotedq.getDqt12jg()==null||scsNotedq.getDqt12bz()==null){
            b = "实验记录填写错误!";
        }else if (!BoolNote(scsNotedq.getDqt1jg())||!BoolNote(scsNotedq.getDqt2jg())||!BoolNote(scsNotedq.getDqt3jg())||!BoolNote(scsNotedq.getDqt4jg())){
            b = "实验记录填写错误!";
        }else if (!BoolNote(scsNotedq.getDqt5jg())||!BoolNote(scsNotedq.getDqt6jg())||!BoolNote(scsNotedq.getDqt7jg())||!BoolNote(scsNotedq.getDqt8jg())){
            b = "实验记录填写错误!";
        }else if (!BoolNote(scsNotedq.getDqt9jg())||!BoolNote(scsNotedq.getDqt10jg())||!BoolNote(scsNotedq.getDqt11jg())||!BoolNote(scsNotedq.getDqt12jg())){
            b = "实验记录填写错误!";
        }else {
            ScsOpsinsp scsOpsinsp = new ScsOpsinsp();
            if (BoolNotedq(scsNotedq)){
                if(opsMapper.findNotect(scsNotedq.getRgstnum())!=null&&opsMapper.findNotect(scsNotedq.getRgstnum()).getCtstate().equals("完成")&&opsMapper.findNotelj(scsNotedq.getRgstnum())!=null&&opsMapper.findNotelj(scsNotedq.getRgstnum()).getLjstate().equals("完成")){
                    scsOpsinsp.setAllstate("完成");
                    opsMapper.completeOps(scsNotedq.getRgstnum());
                }else{
                    scsOpsinsp.setAllstate("电气效用记录表验船师完成");
                }
                scsNotedq.setDqstate("完成");
            }else{
                scsOpsinsp.setAllstate("电气效用记录表验船师受理");
                scsNotedq.setDqstate("未完成");
            }
            scsOpsinsp.setAlltime(getNtime());
            scsOpsinsp.setRgstnum(scsNotedq.getRgstnum());
            opsMapper.updateAll(scsOpsinsp);
            scsNotedq.setDqdate(getNtime());
            opsMapper.updateNotedq(scsNotedq);
            b = "更新电气设备效益试验记录表成功!";
        }
        return new Message(b);
    }


    /*
     * 基本操作
     */
    //新建营运检验-船厂提交
    private String setAddOps(ScsOpsinsp scsOpsinsp){
        String b;
        scsOpsinsp.setRgstnum("sqb"+getSqbnum());
//        if(scsOpsinsp.getRgstnum()!=null&&opsMapper.findOpsByRgstnumForcheck(scsOpsinsp.getRgstnum())!=null&&opsMapper.findOpsByRgstnumForcheck(scsOpsinsp.getRgstnum()).getAuditstate().equals("不予受理")){
//            if(!setDeleteOps(scsOpsinsp.getRgstnum()).equals("删除营运检验成功!")){
//                b = "创建失败!";
//                return b;
//            }
//        }
        if(scsOpsinsp.getCdinfo()!=null&&scsOpsinsp.getCdinfo().equals("")){
            scsOpsinsp.setCdname("");
            scsOpsinsp.setCdusername("");
        }else if(scsOpsinsp.getCdinfo()==null||!chickPeopleInfo(scsOpsinsp.getCdinfo())){
            scsOpsinsp.setCdinfo("cdinfo");
            scsOpsinsp.setCdname("");
            scsOpsinsp.setCdusername("");
        }else {
            String a[] = scsOpsinsp.getCdinfo().split("/");
            scsOpsinsp.setCdname(a[0]);
            scsOpsinsp.setCdusername(a[1]);
        }
        if(scsOpsinsp.getRgstnum()!=null&&opsMapper.findOpsByRgstnumForcheck(scsOpsinsp.getRgstnum())!=null){
            b = "此项目已存在!";
        }else if (scsOpsinsp.getShipname()==null||!chickShipname(scsOpsinsp.getShipname().trim())) {
            b = "船名填写格式错误!";
        }else if (scsOpsinsp.getInspnum()==null||!chickRgstnum(scsOpsinsp.getInspnum())) {
            b = "船检登记号填写格式错误!";
        }else if (scsOpsinsp.getInsptype()==null||!chickInsptype(scsOpsinsp.getInsptype())) {
            b = "检验类型填写错误!";
        }else if (scsOpsinsp.getShiplength()==null||!chickNumber(scsOpsinsp.getShiplength())) {
            b = "总长填写格式错误!";
        }else if (scsOpsinsp.getGrosston()==null||!chickGrosston(scsOpsinsp.getGrosston())) {
            b = "总吨位填写格式错误!";
        }else if (scsOpsinsp.getHostpower()==null||!chickNumber(scsOpsinsp.getHostpower())) {
            b = "主机功率填写格式错误!";
        }else if (scsOpsinsp.getRegion()==null||!chickRegion(scsOpsinsp.getRegion())) {
            b = "航行区域填写错误!";
        }else if (scsOpsinsp.getShipstops()==null||!chickShipstops(scsOpsinsp.getShipstops())) {
            b = "船籍港填写格式错误!";
        }else if (scsOpsinsp.getShiptype()==null||!chickName(scsOpsinsp.getShiptype())) {
            b = "船舶类型填写格式错误!";
        }else if (scsOpsinsp.getInspaddress()==null||!chickName(scsOpsinsp.getInspaddress())) {
            b = "修理地点填写格式错误!";
        }else if (scsOpsinsp.getDockingdate()!=null&&!chickDate(scsOpsinsp.getDockingdate())) {
            b = "进坞时间填写格式错误!";
        }else if (scsOpsinsp.getDockingdate()!=null&&!compareTime(scsOpsinsp.getDockingdate(),0)) {
            b = "进坞时间不能在当天之后!";
        }else if (scsOpsinsp.getApnttime()==null||!chickDate(scsOpsinsp.getApnttime())){
            b = "预约检验时间格式错误!";
        }else if (scsOpsinsp.getApnttime()!=null&&!compareTime(scsOpsinsp.getApnttime(),1)){
            b = "预约检验时间不能在当天之前!";
        }else if (!scsOpsinsp.getCdinfo().equals("")&&(scsOpsinsp.getCdusername().equals("")||scsOpsinsp.getCdname().equals("")||userMapper.validateCd(scsOpsinsp.getCdusername(), scsOpsinsp.getCdname())==null)) {
            b = "船东信息填写错误!";
        }else if(scsOpsinsp.getInfo1()==null||scsOpsinsp.getInfo1adr()==null||scsOpsinsp.getInfo2()==null||scsOpsinsp.getInfo2adr()==null||scsOpsinsp.getInfo3()==null||scsOpsinsp.getInfo3adr()==null||scsOpsinsp.getInfo4()==null||scsOpsinsp.getInfo4name()==null||scsOpsinsp.getInfo4adr()==null){
            b = "提交资料填写错误";
        }else if(!scsOpsinsp.getInfo1()&&!scsOpsinsp.getInfo1adr().equals("")){
            b = "提交资料填写错误";
        }else if(!scsOpsinsp.getInfo2()&&!scsOpsinsp.getInfo2adr().equals("")){
            b = "提交资料填写错误";
        }else if(!scsOpsinsp.getInfo3()&&!scsOpsinsp.getInfo3adr().equals("")){
            b = "提交资料填写错误";
        }else if(!scsOpsinsp.getInfo4()&&(!scsOpsinsp.getInfo4adr().equals("")||!scsOpsinsp.getInfo4name().equals(""))){
            b = "提交资料填写错误";
        }else if(scsOpsinsp.getInfo1()&&scsOpsinsp.getInfo1adr().equals("")){
            b = "提交资料填写错误";
        }else if(scsOpsinsp.getInfo2()&&scsOpsinsp.getInfo2adr().equals("")){
            b = "提交资料填写错误";
        }else if(scsOpsinsp.getInfo3()&&scsOpsinsp.getInfo3adr().equals("")){
            b = "提交资料填写错误";
        }else if(scsOpsinsp.getInfo4()&&(scsOpsinsp.getInfo4adr().equals("")||scsOpsinsp.getInfo4name().equals(""))){
            b = "提交资料填写错误";
        }else if (scsOpsinsp.getApunitname()==null||(!scsOpsinsp.getApunitname().equals("")&&!chickName(scsOpsinsp.getApunitname()))) {
            b = "申请单位名称填写格式错误!";
        }else if (scsOpsinsp.getFax()==null||(!scsOpsinsp.getFax().equals("")&&!chickFax(scsOpsinsp.getFax()))) {
            b = "传真填写格式错误!";
        }else if (scsOpsinsp.getZipcode()==null||(!scsOpsinsp.getZipcode().equals("")&&!chickZipcode(scsOpsinsp.getZipcode()))) {
            b = "邮编填写格式错误!";
        }else if (scsOpsinsp.getCrecode()==null||(!scsOpsinsp.getCrecode().equals("")&&!chickCrecode(scsOpsinsp.getCrecode()))) {
            b = "社会统一代码填写格式错误!";
        }else if (scsOpsinsp.getCcadr()==null||(!scsOpsinsp.getCcadr().equals("")&&!chickCcadr(scsOpsinsp.getCcadr()))) {
            b = "地址填写格式错误!";
        }else if (scsOpsinsp.getWritename()==null||(!scsOpsinsp.getWritename().equals("")&&!chickName(scsOpsinsp.getWritename()))) {
            b = "负责人格式错误!";
        }else if(scsOpsinsp.getCcinfo()==null||!chickCcInfo(scsOpsinsp.getCcinfo())){
            b = "联系人和电话格式错误!";
        }else {
            scsOpsinsp.setShipname(scsOpsinsp.getShipname().trim());
            if(!scsOpsinsp.getCdusername().equals("")){
                String cdid = userMapper.findByUsername(scsOpsinsp.getCdusername()).getUserid();
                scsOpsinsp.setCdid(cdid);
                userJoinPro(cdid, "船东");
            }
            String c[] = scsOpsinsp.getCcinfo().split("/");
            if(c[1]!=null&&userMapper.findByUsername(c[1])!=null){
                String ccid = userMapper.findByUsername(c[1]).getUserid();
                scsOpsinsp.setCcid(ccid);
                userJoinPro(ccid, "船厂");
            }
            Method method = new Method();
            if(scsOpsinsp.getInfo1()){
                method.copyFile(scsOpsinsp.getInfo1adr(),"ops/"+scsOpsinsp.getRgstnum()+"/opsfile1"+scsOpsinsp.getInfo1adr().substring(scsOpsinsp.getInfo1adr().lastIndexOf("/")));
                scsOpsinsp.setInfo1adr("ops/"+scsOpsinsp.getRgstnum()+"/opsfile1"+scsOpsinsp.getInfo1adr().substring(scsOpsinsp.getInfo1adr().lastIndexOf("/")));
            }
            if(scsOpsinsp.getInfo2()){
                method.copyFile(scsOpsinsp.getInfo2adr(),"ops/"+scsOpsinsp.getRgstnum()+"/opsfile2"+scsOpsinsp.getInfo2adr().substring(scsOpsinsp.getInfo2adr().lastIndexOf("/")));
                scsOpsinsp.setInfo2adr("ops/"+scsOpsinsp.getRgstnum()+"/opsfile2"+scsOpsinsp.getInfo2adr().substring(scsOpsinsp.getInfo2adr().lastIndexOf("/")));
            }
            if(scsOpsinsp.getInfo3()){
                method.copyFile(scsOpsinsp.getInfo3adr(),"ops/"+scsOpsinsp.getRgstnum()+"/opsfile3"+scsOpsinsp.getInfo3adr().substring(scsOpsinsp.getInfo3adr().lastIndexOf("/")));
                scsOpsinsp.setInfo3adr("ops/"+scsOpsinsp.getRgstnum()+"/opsfile3"+scsOpsinsp.getInfo3adr().substring(scsOpsinsp.getInfo3adr().lastIndexOf("/")));
            }
            if(scsOpsinsp.getInfo4()){
                method.copyFile(scsOpsinsp.getInfo4adr(),"ops/"+scsOpsinsp.getRgstnum()+"/opsfile4"+scsOpsinsp.getInfo4adr().substring(scsOpsinsp.getInfo4adr().lastIndexOf("/")));
                scsOpsinsp.setInfo4adr("ops/"+scsOpsinsp.getRgstnum()+"/opsfile4"+scsOpsinsp.getInfo4adr().substring(scsOpsinsp.getInfo4adr().lastIndexOf("/")));
            }
            scsOpsinsp.setWritedate(getNtime());
            scsOpsinsp.setLatesttime(getNtime());
            scsOpsinsp.setState("未完成");
            scsOpsinsp.setFlag("未完成");
            scsOpsinsp.setAllstate("申请表船厂提交");
            scsOpsinsp.setAlltime(getNtime());
            opsMapper.saveOps(scsOpsinsp);
            b = "创建成功!";
        }
        return b;
    }

    //更新营运检验-船厂提交
    private String setUpdateOps(ScsOpsinsp scsOpsinsp){
        String b;
        if(scsOpsinsp.getCdinfo()!=null&&scsOpsinsp.getCdinfo().equals("")){
            scsOpsinsp.setCdname("");
            scsOpsinsp.setCdusername("");
        }else if(scsOpsinsp.getCdinfo()==null||!chickPeopleInfo(scsOpsinsp.getCdinfo())){
            scsOpsinsp.setCdinfo("cdinfo");
            scsOpsinsp.setCdname("");
            scsOpsinsp.setCdusername("");
        }else {
            String a[] = scsOpsinsp.getCdinfo().split("/");
            scsOpsinsp.setCdname(a[0]);
            scsOpsinsp.setCdusername(a[1]);
        }
        if(scsOpsinsp.getRgstnum()!=null&&opsMapper.findOpsByRgstnum(scsOpsinsp.getRgstnum())==null){
            b = "此项目不存在!";
        }else if (scsOpsinsp.getShipname()==null||!chickShipname(scsOpsinsp.getShipname().trim())) {
            b = "船名填写格式错误!";
        }else if (scsOpsinsp.getInspnum()==null||!chickRgstnum(scsOpsinsp.getInspnum())) {
            b = "船检登记号填写格式错误!";
        }else if (scsOpsinsp.getInsptype()==null||!chickInsptype(scsOpsinsp.getInsptype())) {
            b = "检验类型填写错误!";
        }else if (scsOpsinsp.getShiplength()==null||!chickNumber(scsOpsinsp.getShiplength())) {
            b = "总长填写格式错误!";
        }else if (scsOpsinsp.getGrosston()==null||!chickGrosston(scsOpsinsp.getGrosston())) {
            b = "总吨位填写格式错误!";
        }else if (scsOpsinsp.getHostpower()==null||!chickNumber(scsOpsinsp.getHostpower())) {
            b = "主机功率填写格式错误!";
        }else if (scsOpsinsp.getRegion()==null||!chickRegion(scsOpsinsp.getRegion())) {
            b = "航行区域填写错误!";
        }else if (scsOpsinsp.getShipstops()==null||!chickShipstops(scsOpsinsp.getShipstops())) {
            b = "船籍港填写格式错误!";
        }else if (scsOpsinsp.getShiptype()==null||!chickName(scsOpsinsp.getShiptype())) {
            b = "船舶类型填写格式错误!";
        }else if (scsOpsinsp.getInspaddress()==null||!chickName(scsOpsinsp.getInspaddress())) {
            b = "修理地点填写格式错误!";
        }else if (scsOpsinsp.getDockingdate()!=null&&!chickDate(scsOpsinsp.getDockingdate())) {
            b = "进坞时间填写格式错误!";
        }else if (scsOpsinsp.getDockingdate()!=null&&!compareTime(scsOpsinsp.getDockingdate(),0)) {
            b = "进坞时间不能在当天之后!";
        }else if (scsOpsinsp.getApnttime()==null||!chickDate(scsOpsinsp.getApnttime())){
            b = "预约检验时间格式错误!";
        }else if (!scsOpsinsp.getApnttime().equals(opsMapper.findOpsByRgstnum(scsOpsinsp.getRgstnum()).getApnttime())&&!compareTime(scsOpsinsp.getApnttime(),1)){
            b = "预约检验时间不能在当天之前!";
        }else if (!scsOpsinsp.getCdinfo().equals("")&&(scsOpsinsp.getCdusername().equals("")||scsOpsinsp.getCdname().equals("")||userMapper.validateCd(scsOpsinsp.getCdusername(), scsOpsinsp.getCdname())==null)) {
            b = "船东信息填写错误!";
        }else if (scsOpsinsp.getApunitname()==null||(!scsOpsinsp.getApunitname().equals("")&&!chickName(scsOpsinsp.getApunitname()))) {
            b = "申请单位名称填写格式错误!";
        }else if (scsOpsinsp.getFax()==null||(!scsOpsinsp.getFax().equals("")&&!chickFax(scsOpsinsp.getFax()))) {
            b = "传真填写格式错误!";
        }else if (scsOpsinsp.getZipcode()==null||(!scsOpsinsp.getZipcode().equals("")&&!chickZipcode(scsOpsinsp.getZipcode()))) {
            b = "邮编填写格式错误!";
        }else if (scsOpsinsp.getCrecode()==null||(!scsOpsinsp.getCrecode().equals("")&&!chickCrecode(scsOpsinsp.getCrecode()))) {
            b = "社会统一代码填写格式错误!";
        }else if (scsOpsinsp.getCcadr()==null||(!scsOpsinsp.getCcadr().equals("")&&!chickCcadr(scsOpsinsp.getCcadr()))) {
            b = "地址填写格式错误!";
        }else if (scsOpsinsp.getWritename()==null||(!scsOpsinsp.getWritename().equals("")&&!chickName(scsOpsinsp.getWritename()))) {
            b = "负责人格式错误!";
        }else if(scsOpsinsp.getCcinfo()==null||!chickCcInfo(scsOpsinsp.getCcinfo())){
            b = "联系人和电话格式错误!";
        }else {
            ScsOpsinsp oldOps = opsMapper.findOpsByRgstnum(scsOpsinsp.getRgstnum());
            userQuitPro(oldOps.getCdid(), "船东");
            userQuitPro(oldOps.getCcid(), "船厂");
            scsOpsinsp.setShipname(scsOpsinsp.getShipname().trim());
            if(!scsOpsinsp.getCdusername().equals("")){
                String cdid = userMapper.findByUsername(scsOpsinsp.getCdusername()).getUserid();
                scsOpsinsp.setCdid(cdid);
                userJoinPro(cdid, "船东");
            }
            String c[] = scsOpsinsp.getCcinfo().split("/");
            if(c[1]!=null&&userMapper.findByUsername(c[1]).getUserid()!=null){
                String ccid = userMapper.findByUsername(c[1]).getUserid();
                scsOpsinsp.setCcid(ccid);
                userJoinPro(ccid, "船厂");
            }
            scsOpsinsp.setWritedate(getNtime());
            scsOpsinsp.setLatesttime(getNtime());
            scsOpsinsp.setAllstate("申请表船厂提交");
            scsOpsinsp.setAlltime(getNtime());
            opsMapper.updateAll(scsOpsinsp);
            opsMapper.updateOps(scsOpsinsp);
            b = "更新成功!";
        }
        return b;
    }

    //更新营运检验-船检处审核
    private String setUpdateOpsCjc(ScsOpsinsp scsOpsinsp){
        String b;
        if(scsOpsinsp.getYcs1info()==null||scsOpsinsp.getYcs1info().equals("")||!chickPeopleInfo(scsOpsinsp.getYcs1info())){
            scsOpsinsp.setYcs1info("");
            scsOpsinsp.setYcs1name("");
            scsOpsinsp.setYcs1username("");
        }else {
            String c[] = scsOpsinsp.getYcs1info().split("/");
            scsOpsinsp.setYcs1name(c[0]);
            scsOpsinsp.setYcs1username(c[1]);
        }
        if(scsOpsinsp.getYcs2info()==null||scsOpsinsp.getYcs2info().equals("")||!chickPeopleInfo(scsOpsinsp.getYcs2info())){
            scsOpsinsp.setYcs2info("");
            scsOpsinsp.setYcs2name("");
            scsOpsinsp.setYcs2username("");
        }else {
            String d[] = scsOpsinsp.getYcs2info().split("/");
            scsOpsinsp.setYcs2name(d[0]);
            scsOpsinsp.setYcs2username(d[1]);
        }
        if(scsOpsinsp.getYcs3info()==null||scsOpsinsp.getYcs3info().equals("")||!chickPeopleInfo(scsOpsinsp.getYcs3info())){
            scsOpsinsp.setYcs3info("");
            scsOpsinsp.setYcs3name("");
            scsOpsinsp.setYcs3username("");
        }else {
            String e[] = scsOpsinsp.getYcs3info().split("/");
            scsOpsinsp.setYcs3name(e[0]);
            scsOpsinsp.setYcs3username(e[1]);
        }
        if(scsOpsinsp.getAuditopn()==null){
            scsOpsinsp.setAuditopn("");
        }
        if(scsOpsinsp.getHeadman()==null||scsOpsinsp.getHeadman()<0||scsOpsinsp.getHeadman()>3){
            scsOpsinsp.setHeadman(0);
        }
        if(scsOpsinsp.getRgstnum()==null||opsMapper.findOpsByRgstnum(scsOpsinsp.getRgstnum())==null){
            b = "此项目不存在!";
        }else if (scsOpsinsp.getAuditstate()==null||!chickAuditstate(scsOpsinsp.getAuditstate())) {
            b = "受理状态填写格式错误!";
        }else if(scsOpsinsp.getArgstnum()==null){
            b = "检验编号填写格式错误!";
        }else if(opsMapper.findOpsByRgstnum(scsOpsinsp.getArgstnum())!=null){
            b = "该检验编号项目已存在!";
        }else if (scsOpsinsp.getArgstnum().equals("不予受理")&&!scsOpsinsp.getArgstnum().equals("")) {
            b = "检验编号填写格式错误!";
        }else if (scsOpsinsp.getArgstnum().equals("同意受理")&&opsMapper.findOpsByRgstnum(scsOpsinsp.getRgstnum()).getAuditstate().equals("")&&(scsOpsinsp.getArgstnum()==null||!chickRgstnum(scsOpsinsp.getArgstnum()))) {
            b = "检验编号填写格式错误!";
        }else if (!scsOpsinsp.getYcs1info().equals("")&&userMapper.validateYcs(scsOpsinsp.getYcs1username(), scsOpsinsp.getYcs1name())==null) {
            b = "验船师成员1信息填写错误!";
        }else if (!scsOpsinsp.getYcs2info().equals("")&&userMapper.validateYcs(scsOpsinsp.getYcs2username(), scsOpsinsp.getYcs2name())==null) {
            b = "验船师成员2信息填写错误!";
        }else if (!scsOpsinsp.getYcs3info().equals("")&&userMapper.validateYcs(scsOpsinsp.getYcs3username(), scsOpsinsp.getYcs3name())==null) {
            b = "验船师成员3信息填写错误!";
        }else if(scsOpsinsp.getAuditstate().equals("不予受理")&&scsOpsinsp.getAuditopn().equals("")){
            b = "请填写审核意见!";
        }else if (scsOpsinsp.getAuditstate().equals("同意受理")&&scsOpsinsp.getYcs1info().equals("")&&scsOpsinsp.getYcs2info().equals("")&&scsOpsinsp.getYcs3info().equals("")){
            b = "检验组成员信息错误!";
        }else if (scsOpsinsp.getAuditstate().equals("同意受理")&&(scsOpsinsp.getHeadman().equals(0)||(scsOpsinsp.getHeadman().equals(1)&&scsOpsinsp.getYcs1info().equals(""))||(scsOpsinsp.getHeadman().equals(2)&&scsOpsinsp.getYcs2info().equals(""))||(scsOpsinsp.getHeadman().equals(3)&&scsOpsinsp.getYcs3info().equals("")))){
            b = "检验组成员信息错误!";
        }else {
            ScsOpsinsp oldOps = opsMapper.findOpsByRgstnum(scsOpsinsp.getRgstnum());
            if(oldOps.getYcs1id()!=null){
                userQuitPro(oldOps.getYcs1id(), "验船师");
            }
            if(oldOps.getYcs2id()!=null){
                userQuitPro(oldOps.getYcs2id(), "验船师");
            }
            if(oldOps.getYcs3id()!=null){
                userQuitPro(oldOps.getYcs3id(), "验船师");
            }
            if(!scsOpsinsp.getYcs1username().equals("")){
                String ycs1id = userMapper.findByUsername(scsOpsinsp.getYcs1username()).getUserid();
                scsOpsinsp.setYcs1id(ycs1id);
                userJoinPro(ycs1id, "验船师");
            }
            if(!scsOpsinsp.getYcs2username().equals("")){
                String ycs2id = userMapper.findByUsername(scsOpsinsp.getYcs2username()).getUserid();
                scsOpsinsp.setYcs2id(ycs2id);
                userJoinPro(ycs2id, "验船师");
            }
            if(!scsOpsinsp.getYcs3username().equals("")){
                String ycs3id = userMapper.findByUsername(scsOpsinsp.getYcs3username()).getUserid();
                scsOpsinsp.setYcs3id(ycs3id);
                userJoinPro(ycs3id, "验船师");
            }
            if(scsOpsinsp.getAuditstate().equals("不予受理")){
                scsOpsinsp.setAllstate("申请表船检处审核不予受理");
                opsMapper.uncompleteOps(scsOpsinsp.getRgstnum());
            }else{
                scsOpsinsp.setAuditopn("");
                scsOpsinsp.setAllstate("申请表船检处审核同意受理");
            }
            scsOpsinsp.setAuditdate(getNtime());
            scsOpsinsp.setLatesttime(getNtime());
            scsOpsinsp.setAlltime(getNtime());
            if(!scsOpsinsp.getArgstnum().equals("")){
                opsMapper.updateOpsCjcjy(scsOpsinsp);
            }else{
                opsMapper.updateOpsCjc(scsOpsinsp);
            }
            opsMapper.updateAll(scsOpsinsp);
            b = "更新成功!";
        }
        return b;
    }

    //禁用营运检验
    private String setForbidOps(String rgstnum){
        String b;
        if(rgstnum==null||opsMapper.findOpsByRgstnum(rgstnum)==null){
            b = "该项目不存在!";
        }else if (opsMapper.findOpsByRgstnum(rgstnum).getState().equals("禁用")) {
            b = "请勿重复操作!";
        }else {
            opsMapper.forbidOps(rgstnum);
            b = "禁用营运检验成功!";
        }
        return b;
    }

    //恢复营运检验
    private String setRenewOps(String rgstnum){
        String b;
        if(rgstnum==null||opsMapper.findOpsByRgstnum(rgstnum)==null){
            b = "该项目不存在!";
        }else if (!opsMapper.findOpsByRgstnum(rgstnum).getState().equals("禁用")) {
            b = "请勿重复操作!";
        }else {
            opsMapper.renewOps(rgstnum);
            b = "恢复营运检验成功!";
        }
        return b;
    }

    //删除营运检验
    private String setDeleteOps(String rgstnum){
        String b;
        if(rgstnum==null||opsMapper.findOpsByRgstnum(rgstnum)==null){
            b = "该项目不存在!";
        }else {
            Method method = new Method();
            String path = "const/"+rgstnum;
            String classPath = this.getClass().getClassLoader().getResource("").getPath();
            String thepath = classPath.substring(0,classPath.indexOf("WEB-INF"))+"file/";
            path = thepath+path;
            File dir = new File(path);
            method.deleteDir(dir);           //删除所有文件
            opsMapper.deleteOps(rgstnum);   //删除营运检验申请表
            opsMapper.deleteQcc(rgstnum);   //删除质量控制表
            opsMapper.deleteNotect(rgstnum);//删除船体设备效益试验记录表
            opsMapper.deleteNotelj(rgstnum);//删除轮机设备效益试验记录表
            opsMapper.deleteNotedq(rgstnum);//删除电气设备效益试验记录表
            b = "删除营运检验成功!";
        }
        return b;
    }

    //新建质量控制表
    private String setAddQcc(ScsQcc scsQcc){
        String b;
        if(scsQcc.getRgstnum()!=null&&opsMapper.findQcc(scsQcc.getRgstnum())!=null){
            b = "质量控制表已存在!";
        }else if (scsQcc.getRgstnum()==null||!chickRgstnum(scsQcc.getRgstnum())){
            b = "船检登记号格式错误!";
        }else if (scsQcc.getQccname()==null||!chickPeoplename(scsQcc.getQccname())){
            b = "验船师姓名格式错误!";
        }else if (scsQcc.getTest1()==null){
            b = "说明格式错误!";
        }else if (scsQcc.getTest2d1()==null||scsQcc.getTest2d2()==null||scsQcc.getTest2d3()==null||scsQcc.getTest2d4()==null||scsQcc.getTest2d5()==null||scsQcc.getTest2d6()==null||scsQcc.getTest2d7()==null||scsQcc.getTest2d8()==null||scsQcc.getTest2d9()==null||scsQcc.getTest2d10()==null){
            b = "报告格式错误!";
        }else if (scsQcc.getTest3()==null){
            b = "需增加的检验项目和检验要求格式错误!";
        }else {
            scsQcc.setQccdate(getNtime());
            ScsOpsinsp scsOpsinsp = new ScsOpsinsp();
            scsOpsinsp.setRgstnum(scsQcc.getRgstnum());
            scsOpsinsp.setAllstate("质量控制表验船师受理");
            scsOpsinsp.setAlltime(getNtime());
            opsMapper.saveQcc(scsQcc);
            opsMapper.updateAll(scsOpsinsp);
            b = "质量控制表创建成功!";
        }
        return b;
    }

    //更新质量控制表
    private String setUpdateQcc(ScsQcc scsQcc){
        String b;
        if(scsQcc.getRgstnum()!=null&&opsMapper.findQcc(scsQcc.getRgstnum())==null){
            b = "质量控制表不存在!";
        }else if (scsQcc.getRgstnum()==null||!chickRgstnum(scsQcc.getRgstnum())){
            b = "船检登记号格式错误!";
        }else if (scsQcc.getQccname()==null||!chickPeoplename(scsQcc.getQccname())){
            b = "验船师姓名格式错误!";
        }else if (scsQcc.getTest1()==null){
            b = "说明格式错误!";
        }else if (scsQcc.getTest2d1()==null||scsQcc.getTest2d2()==null||scsQcc.getTest2d3()==null||scsQcc.getTest2d4()==null||scsQcc.getTest2d5()==null||scsQcc.getTest2d6()==null||scsQcc.getTest2d7()==null||scsQcc.getTest2d8()==null||scsQcc.getTest2d9()==null||scsQcc.getTest2d10()==null){
            b = "报告格式错误!";
        }else if (scsQcc.getTest3()==null){
            b = "需增加的检验项目和检验要求格式错误!";
        }else {
            scsQcc.setQccdate(getNtime());
            ScsOpsinsp scsOpsinsp = new ScsOpsinsp();
            scsOpsinsp.setRgstnum(scsQcc.getRgstnum());
            scsOpsinsp.setAllstate("质量控制表验船师受理");
            scsOpsinsp.setAlltime(getNtime());
            opsMapper.updateQcc(scsQcc);
            opsMapper.updateAll(scsOpsinsp);
            b = "更新质量控制表成功!";
        }
        return b;
    }

    //更新质量控制表-船东意见
    private String setUpdateQccCd(ScsQcc scsQcc){
        String b;
        if(scsQcc.getRgstnum()!=null&&opsMapper.findQcc(scsQcc.getRgstnum())==null){
            b = "质量控制表不存在!";
        }else if(!chickPass(scsQcc.getCdopn())){
            b = "船东意见格式填写错误!";
        }else {
            Date date = new Date();
            DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
            String str = format.format(date);
            scsQcc.setCdopndate(str);
            opsMapper.updateQccCd(scsQcc);
            b = "更新质量控制表成功!";
        }
        return b;
    }


    /*
     * 其他操作
     */
    //获取当前时间
    private Date getNtime(){
        Date date = new Date();
        return new Timestamp(date.getTime());
    }

    private String getSqbnum(){
        Date date = new Date();
        SimpleDateFormat matter=new SimpleDateFormat("yyyyMMddHHmmssSSS");
        return matter.format(date);
    }

    //比较日期 way==1,之后；way==0,之前
    private boolean compareTime(Date adate, int way){
        Date date = new Date();
        SimpleDateFormat matter=new SimpleDateFormat("yyyy-MM-dd");
        String comparedate = matter.format(date);
        String aadate = matter.format(adate);
        if(way==1){
            if(aadate.compareTo(comparedate)>=0){
                return true;
            }else {
                return false;
            }
        }
        if(way==0){
            if(aadate.compareTo(comparedate)<=0){
                return true;
            }else {
                return false;
            }
        }
        return false;
    }

    //检验日期格式
    private boolean chickDate(Date aDate){
        DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        String strDate = format.format(aDate);
        Pattern pattern = Pattern.compile("([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8])))");
        Matcher match=pattern.matcher(strDate);
        return match.matches();
    }

    //检验 船检登记号 检验编号 格式
    private boolean chickRgstnum(String rgstnum){
        Pattern pattern = Pattern.compile("^[A-Za-z0-9]{1,20}$");
        Matcher match=pattern.matcher(rgstnum);
        return match.matches();
    }

    //检验姓名
    private boolean chickPeoplename(String name){
        Pattern pattern = Pattern.compile("(^[\u4e00-\u9fa5]{2,4}$)|(^[a-zA-Z]{3,7}$)");
        Matcher match=pattern.matcher(name);
        return match.matches();
    }

    //检验验船师 船东 船厂 信息格式
    private boolean chickPeopleInfo(String info){
        Pattern pattern = Pattern.compile("(^[\u4e00-\u9fa5]{2,4}/1[345789]\\d{9}$)|(^[a-zA-Z]{3,7}/1[345789]\\d{9}$)");
        Matcher match=pattern.matcher(info);
        return match.matches();
    }

    //检验船厂 信息格式
    private boolean chickCcInfo(String info){
        Pattern pattern = Pattern.compile("(^[\u4e00-\u9fa5]{2,4}/\\d{1,20}$)|(^[a-zA-Z]{3,7}/\\d{1,20}$)");
        Matcher match=pattern.matcher(info);
        return match.matches();
    }

    //检验船名格式
    private boolean chickShipname(String shipname){
        Pattern pattern = Pattern.compile("^[\\s\u4E00-\u9FA5A-Za-z0-9]{1,20}$");
        Matcher match=pattern.matcher(shipname);
        return match.matches();
    }

    //检验 单位名 船名 修理地点 提交资料名称 申请单位名称 格式
    private boolean chickName(String name){
        Pattern pattern = Pattern.compile("^[\u4E00-\u9FA5A-Za-z0-9]{1,20}$");
        Matcher match=pattern.matcher(name);
        return match.matches();
    }

    //检验 船籍港 格式
    private boolean chickShipstops(String shipstops){
        Pattern pattern = Pattern.compile("^[\u4E00-\u9FA5]{1,20}$");
        Matcher match=pattern.matcher(shipstops);
        return match.matches();
    }

    //检验检验类型格式
    private boolean chickInsptype(String insptype){
        Pattern pattern = Pattern.compile("^[0-9A-Za-z\u4e00-\u9fa5]{1,10}$");
        Matcher match=pattern.matcher(insptype);
        return match.matches();
    }

    //检验航行区域格式
    private boolean chickRegion(String region){
        Pattern pattern = Pattern.compile("^[0-9A-Za-z\u4e00-\u9fa5]{1,10}$");
        Matcher match=pattern.matcher(region);
        return match.matches();
    }

    //检验总长 主机功率 格式
    private boolean chickNumber(String number){
        Pattern pattern = Pattern.compile("^[1-9]\\d{0,7}\\.\\d{2}|0\\.\\d{2}$");
        Matcher match=pattern.matcher(number);
        return match.matches();
    }

    //总吨位格式
    private boolean chickGrosston(String number){
        Pattern pattern = Pattern.compile("^[1-9]\\d{0,6}$");
        Matcher match=pattern.matcher(number);
        return match.matches();
    }

    //检验传真格式
    private boolean chickFax(String fax){
        Pattern pattern = Pattern.compile("^.{1,20}$");
        Matcher match=pattern.matcher(fax);
        return match.matches();
    }

    //检验邮编格式
    private boolean chickZipcode(String zipcode){
        Pattern pattern = Pattern.compile("^.{1,20}$");
        Matcher match=pattern.matcher(zipcode);
        return match.matches();
    }

    //检验社会信用统一代码格式
    private boolean chickCrecode(String crecode){
        Pattern pattern = Pattern.compile("^[0-9A-Z]{18}$");
        Matcher match=pattern.matcher(crecode);
        return match.matches();
    }

    //检验船厂地址
    private boolean chickCcadr(String ccadr){
        Pattern pattern = Pattern.compile("^[\u4e00-\u9fa5\\(\\)\\（\\）A-Za-z0-9]{2,30}$");
        Matcher match=pattern.matcher(ccadr);
        return match.matches();
    }

    //检验受理状态格式
    private boolean chickAuditstate(String auditstate){
        Boolean b = false;
        if(auditstate.equals("同意受理")||auditstate.equals("不予受理")){
            b = true;
        }
        return b;
    }

    private boolean BoolNote(String notejg){
        Boolean b = false;
        if(notejg.equals("现状良好")||notejg.equals("此项不检查")||notejg.equals("需要维修")||notejg.equals("")){
            b = true;
        }
        return b;
    }

    private boolean BoolNotect(ScsNotect scsNotect){
        Boolean b = false;
        if((scsNotect.getCtt1jg().equals("现状良好")||scsNotect.getCtt1jg().equals("此项不检查"))&&(scsNotect.getCtt2jg().equals("现状良好")||scsNotect.getCtt2jg().equals("此项不检查"))&&(scsNotect.getCtt3jg().equals("现状良好")||scsNotect.getCtt3jg().equals("此项不检查"))
                &&(scsNotect.getCtt4jg().equals("现状良好")||scsNotect.getCtt4jg().equals("此项不检查"))&&(scsNotect.getCtt5jg().equals("现状良好")||scsNotect.getCtt5jg().equals("此项不检查"))&&(scsNotect.getCtt6jg().equals("现状良好")||scsNotect.getCtt6jg().equals("此项不检查"))
                &&(scsNotect.getCtt7jg().equals("现状良好")||scsNotect.getCtt7jg().equals("此项不检查"))&&(scsNotect.getCtt8jg().equals("现状良好")||scsNotect.getCtt8jg().equals("此项不检查"))&&(scsNotect.getCtt9jg().equals("现状良好")||scsNotect.getCtt9jg().equals("此项不检查"))
                &&(scsNotect.getCtt10jg().equals("现状良好")||scsNotect.getCtt10jg().equals("此项不检查"))&&(scsNotect.getCtt11jg().equals("现状良好")||scsNotect.getCtt11jg().equals("此项不检查"))){
            b = true;
        }
        return b;
    }

    private boolean BoolNotelj(ScsNotelj scsNotelj){
        Boolean b = false;
        if((scsNotelj.getLjt1jg().equals("现状良好")||scsNotelj.getLjt1jg().equals("此项不检查"))&&(scsNotelj.getLjt2jg().equals("现状良好")||scsNotelj.getLjt2jg().equals("此项不检查"))&&(scsNotelj.getLjt3jg().equals("现状良好")||scsNotelj.getLjt3jg().equals("此项不检查"))
                &&(scsNotelj.getLjt4jg().equals("现状良好")||scsNotelj.getLjt4jg().equals("此项不检查"))&&(scsNotelj.getLjt5jg().equals("现状良好")||scsNotelj.getLjt5jg().equals("此项不检查"))&&(scsNotelj.getLjt6jg().equals("现状良好")||scsNotelj.getLjt6jg().equals("此项不检查"))
                &&(scsNotelj.getLjt7jg().equals("现状良好")||scsNotelj.getLjt7jg().equals("此项不检查"))&&(scsNotelj.getLjt8jg().equals("现状良好")||scsNotelj.getLjt8jg().equals("此项不检查"))&&(scsNotelj.getLjt9jg().equals("现状良好")||scsNotelj.getLjt9jg().equals("此项不检查"))
                &&(scsNotelj.getLjt10jg().equals("现状良好")||scsNotelj.getLjt10jg().equals("此项不检查"))&&(scsNotelj.getLjt11jg().equals("现状良好")||scsNotelj.getLjt11jg().equals("此项不检查"))&&(scsNotelj.getLjt12jg().equals("现状良好")||scsNotelj.getLjt12jg().equals("此项不检查"))){
            b = true;
        }
        return b;
    }

    private boolean BoolNotedq(ScsNotedq scsNotedq){
        Boolean b = false;
        if((scsNotedq.getDqt1jg().equals("现状良好")||scsNotedq.getDqt1jg().equals("此项不检查"))&&(scsNotedq.getDqt2jg().equals("现状良好")||scsNotedq.getDqt2jg().equals("此项不检查"))&&(scsNotedq.getDqt3jg().equals("现状良好")||scsNotedq.getDqt3jg().equals("此项不检查"))
                &&(scsNotedq.getDqt4jg().equals("现状良好")||scsNotedq.getDqt4jg().equals("此项不检查"))&&(scsNotedq.getDqt5jg().equals("现状良好")||scsNotedq.getDqt5jg().equals("此项不检查"))&&(scsNotedq.getDqt6jg().equals("现状良好")||scsNotedq.getDqt6jg().equals("此项不检查"))
                &&(scsNotedq.getDqt7jg().equals("现状良好")||scsNotedq.getDqt7jg().equals("此项不检查"))&&(scsNotedq.getDqt8jg().equals("现状良好")||scsNotedq.getDqt8jg().equals("此项不检查"))&&(scsNotedq.getDqt9jg().equals("现状良好")||scsNotedq.getDqt9jg().equals("此项不检查"))
                &&(scsNotedq.getDqt10jg().equals("现状良好")||scsNotedq.getDqt10jg().equals("此项不检查"))&&(scsNotedq.getDqt11jg().equals("现状良好")||scsNotedq.getDqt11jg().equals("此项不检查"))&&(scsNotedq.getDqt12jg().equals("现状良好")||scsNotedq.getDqt12jg().equals("此项不检查"))){
            b = true;
        }
        return b;
    }

    //检验意见
    private boolean chickPass(String pass){
        Boolean b = false;
        if(pass.equals("通过")||pass.equals("不通过")){
            b = true;
        }
        return b;
    }

    //用户加入项目
    public void userJoinPro(String userid, String type){
        switch (type){
            case "验船师":
                userMapper.ycsJoinPro(userid);
                break;
            case "船厂":
                userMapper.ccJoinPro(userid);
                break;
            case "船东":
                userMapper.cdJoinPro(userid);
                break;
            default:
                break;
        }
    }

    //用户退出项目
    public void userQuitPro(String userid, String type){
        switch (type){
            case "验船师":
                userMapper.ycsQuitPro(userid);
                break;
            case "船厂":
                userMapper.ccQuitPro(userid);
                break;
            case "船东":
                userMapper.cdQuitPro(userid);
                break;
            default:
                break;
        }
    }
}